<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.welfare.admin.system.*" %>
<%
	String job_type = StringUtil.nvl(request.getParameter("job_type"),"C");
	String docu_id 	= StringUtil.nvl(request.getParameter("docu_id"));
	
	if (!"".equals(docu_id)) {
		job_type = "U";
	}
	
	HashMap infos = new HashMap();
	infos.put("docu_id", docu_id);
	
	SystemDAO dao 	= new SystemDAO();
	HashList list 	= dao.selectDocumentInfo(infos);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= SYSTEM_NAME %></title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>

	<script type="text/javascript">
	
	
	$(document).ready(function() {
		
	
	});

	
	function fnSave() {
		if ($('#job_type').val() == 'D') {
			return true;
		} else if ($('#job_type').val() == 'U') {
			if (cfCheckRequired(document.saveForm.docu_name, '서식명을 입력하세요')) {
				return true;
			} else {
				return false;
			}
		} else {
			if (cfCheckRequired(document.saveForm.docu_name, '서식명을 입력하세요')
					&& cfCheckRequired(document.saveForm.file_path, '첨부파일을 추가해주세요')) {
				return true;
			} else {
				return false;
			}
		}
	}
	
	function fnDelete() {
		if (confirm(MSG_DELETE)) {
			$('#job_type').val('D');
			$('#saveForm').submit();
		}
	}
	

	</script>
</head>
<body>
<div id="wrap">
	<div id="popup">
		<div class="menu_title">
			<h1>서식 등록</h1>
			<div class="r mt2"></div>
		</div>
		<div class="clear line_01"></div>

		<form id="saveForm" name="saveForm" action="./documentSave.do" method="post" enctype="multipart/form-data" onsubmit="return fnSave()">
		<input type="hidden" name="job_type" id="job_type" value="<%= job_type %>"/>
		<input type="hidden" name="docu_id" value="<%= docu_id %>"/>
		<input type="hidden" name="file_id" value="<%= list.get("file_id",0) %>"/>
		<table cellpadding="0" cellspacing="0" class="table_01 mt5">
			<colgroup>
				<col width="100px"/>
				<col/>
			</colgroup>
			<tbody>
				<tr>
					<th><p><label for="docu_name">서식명</label></p></th>
					<td class="brx">
						<input type="text" name="docu_name" id="docu_name" value="<%= list.get("docu_name",0) %>" class="wmax"/>
					</td>
				</tr>
				<tr>
					<th><p>저장위치</p></th>
					<td class="brx">
						<%= list.get("file_path", 0) %> 
					</td>
				</tr>
				<tr>
					<th><p><label for="docu_name">파일첨부</label></p></th>
					<td class="brx">
						<input type="file" name="file_path" id="file_path" class="wmax"/>
					</td>
				</tr>
			</tbody>
		</table>
		
		<div class="mt20 mb10 c">
	<%	if ("C".equals(job_type)) { %>
			<input type="image" class="button" src="../images/btn_register.gif" />
	<%	} else if ("U".equals(job_type)) { %>
			<input type="image" class="button" src="../images/btn_update.gif" />
			<a href="#nohref" onclick="fnDelete()"><img src="../images/btn_delete.gif" /></a>
	<%	} %>
			<a href="#nohref" onclick="self.close()"><img src="../images/btn_cancel.gif" /></a>
		</div>
	
		</form>
		
	</div>
</div>

</body>
</html>
